package com.openness.spider.zk.lock;

import java.util.concurrent.CountDownLatch;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

/**
 * @author Rain
 * @version 2013-6-19 下午10:10:48
 */

public class WatcherLatch implements Watcher {

	private CountDownLatch latch;

	public WatcherLatch() {
		latch = new CountDownLatch(1);
	}

	@Override
	public void process(WatchedEvent event) {
		latch.countDown();
	}

	public void await() throws InterruptedException {
		latch.await();
	}

}
